<?php if (!defined('BASIC_PATH')) exit;
$password = C('password');
if ($password === false) {
    $_SESSION['wbox_is_login'] = true;
    header('Location: index.php');
    die();
}
$showAlert = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (!isset($_POST['password']) || empty($_POST['password'])) {
        $showAlert = '密码为空';
    } elseif ($_POST['password'] == $password) {
        $_SESSION['wbox_is_login'] = true;
        header('Location: index.php');
        die();
    }
    $showAlert = '密码错误';
}
require('header.php');
?>
    <div class="p-5 mb-4 rounded-3">
        <div class="row align-items-center g-lg-5 py-5">
            
            <div class="col-lg-7 text-center text-lg-start">
                
                <h1 class="display-5 fw-bold lh-2 mb-3"><?php C('sys_name', true); ?></h1>
                <p class="col-lg-10 fs-5">这是一个简易的文件/文字分享工具，支持私有或公共匿名方式上传文件，支持短连接来分享文件文字，支持多文件上传，支持文件过期选项，支持二维码分享...</p>
            </div>
            <div class="col-md-10 mx-auto col-lg-5">
                <form class="p-4 p-md-5 border rounded-3 bg-light" method="post">
                    <img class="d-block mx-auto mb-1" src="assets/logo.svg" alt="" width="72" height="72"
                         style="border-radius: 50%">
                    <h3 class="text-center mb-4">用户登录</h3>
                    <?php
                    echo $showAlert ? "<div class='alert alert-danger alert-dismissible fade show py-2 mb-4' role='alert'><strong >$showAlert</strong><button type='button' class='btn-close pb-2' data-bs-dismiss='alert' aria-label='Close'></button></div>" : '';
                    ?>
                    <div class="form-floating mb-3">
                        <input type="password" name="password" class="form-control" id="floatingPassword"
                               placeholder="密码" required>
                        <label for="floatingPassword">密码</label>
                    </div>

                    <button class="w-100 btn btn-lg btn-primary" type="submit">登 录</button>
                    <hr class="my-4">
                    <small class="text-muted">可开启匿名上传无需登录.</small>
                </form>
            </div>
        </div>
    </div>
<?php require('footer.php'); ?>